Conversation
- added cc and bcc when saving drafts - save drafts less aggresively
chore: simplify and fix the dev env
* Create prompts with XML formatting * Include XML formatted prompts in generate func * remove unused regex and add helper functions/warnings * error handling * Update apps/mail/lib/prompts.ts Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * lint issues * Update prompts.ts * #706 (comment) Coderabbit fix 1 * erabbitai bot 3 days ago⚠️ Potential issue errorOccurred state is stale inside finally React state setters (setErrorOccurred) are asynchronous; the errorOccurred value captured at render time will not yet reflect changes made earlier in the same event loop. Consequently, the logic deciding whether to collapse/expand may run with an outdated flag. - } finally { - setIsLoading(false); - if (!errorOccurred || isAskingQuestion) { - setIsExpanded(true); - } else { - setIsExpanded(false); // Collapse on errors - } - } + } finally { + setIsLoading(false); + // Use a local flag to track errors deterministically + const hadError = isAskingQuestion ? false : !!errorFlagRef.current; + setIsExpanded(!hadError); + } You can create const errorFlagRef = useRef(false); and update errorFlagRef.current = true every time an error is detected, ensuring reliable behaviour irrespective of React batching. Committable suggestion skipped: line range outside the PR's diff. * #706 (comment) * #706 (comment) * #706 (comment) --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
…users (#726) * feat(i18n): add Vietnamese language support Add Vietnamese ('vi') to the list of supported languages in the i18n configuration and JSON file to expand language options. * Add a new Vietnamese translation file to support Vietnamese language users. * Clear Vietnamese translation strings
Co-authored-by: needle <122770437+needleXO@users.noreply.github.com>
* Updated lockfile * Updated home page session validation --------- Co-authored-by: Adam <x_1337@outlook.com>
* Create route og image * resolve coderabbit nitpicks --------- Co-authored-by: Adam <x_1337@outlook.com>
- updates lib/auth.ts to use the new method - updates actions/user.ts - updates app/(routes)/settings/danger-zone/page.tsx
…mponent - Added posthog-js version 1.236.6 to package.json and bun.lock. - Introduced search functionality by implementing handleFilterByLabel in NavMain component. - Updated NavItem to trigger label filtering on click.
- Updated NavItem to include an onClick prop for the Link component, allowing for custom click behavior. - Maintained existing functionality with prefetch and target attributes.
* delete mails permanently from bin * add English translations for delete mail actions * update the call handleDelete * fixed handle delete function * handleDelete call * enhance handledelete to reset bulk selection after deletion * removed the scope * delete mails permanently from bin * add English translations for delete mail actions * update the call handleDelete * handleDelete call * enhance handledelete to reset bulk selection after deletion * removed the scope --------- Co-authored-by: Ahmet Kilinc <akx9@icloud.com> Co-authored-by: Adam <x_1337@outlook.com>
* Add sendDraft method to Gmail driver and MailManager interface * fix sendDraft method * Add support for sending draft emails and clear draftId after sending --------- Co-authored-by: Adam <x_1337@outlook.com>
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
Warning Rate limit exceeded@MrgSub has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 22 minutes and 46 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
WalkthroughThis update introduces several new features and enhancements to the mail application. Notably, it adds functionality for deleting mail threads directly from the bin, including new backend actions and UI context menu integration. The email sending workflow is expanded to support sending draft emails, with corresponding changes to driver interfaces and implementations. Inline editing of email addresses is now supported in the compose interface. Localization is broadened with the addition of Simplified and Traditional Chinese language files and language support entries. New status messages for deletion actions are added to English localization. Additional changes include a test script for sending emails, a new dependency for DOM sanitization, and minor UI improvements. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant UI
participant Actions
participant Driver
User->>UI: Right-click thread in bin, select "Delete from Bin"
UI->>Actions: handleDelete(threadId)
Actions->>Driver: delete(threadId)
Driver-->>Actions: success/failure
Actions-->>UI: Return result
UI-->>User: Show toast (success/error)
sequenceDiagram
participant User
participant ComposeUI
participant Actions
participant Driver
User->>ComposeUI: Edit email address inline
ComposeUI->>ComposeUI: handleEditEmail updates state
User->>ComposeUI: Send email
ComposeUI->>Actions: sendEmail(emailData, [draftId])
alt draftId is provided
Actions->>Driver: sendDraft(draftId, emailData)
else no draftId
Actions->>Driver: create(emailData)
end
Driver-->>Actions: success/failure
Actions-->>ComposeUI: Return result
ComposeUI-->>User: Show result, clear draftId if sent
Possibly related PRs
Suggested reviewers
Poem
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (6)
apps/mail/components/context/thread-context.tsx (1)
239-253: Inconsistent indentation and spacing issues.The implementation of
handleDeletefunction has inconsistent indentation (tabs instead of spaces) and a formatting issue in the error logging.Apply this diff to fix the indentation and spacing:
const handleDelete = () => async () => { - try { + try { const promise = deleteThread({ id: threadId }).then(() => { setMail(prev => ({ ...prev, bulkSelected: [] })); return mutate(); }); toast.promise(promise, { loading: t('common.actions.deletingMail'), success: t('common.actions.deletedMail'), error: t('common.actions.failedToDeleteMail'), }); } catch (error) { - console.error(`Error deleting ${threadId? 'email' : 'thread'}:`, error); + console.error(`Error deleting ${threadId ? 'email' : 'thread'}:`, error); } };The function otherwise correctly implements the deletion workflow with appropriate error handling and user notifications.
apps/mail/scripts.ts (2)
40-43: Add exponential backoff for reliable testing.The current random delay implementation is simple but doesn't handle rate limiting properly. For more robust testing, consider implementing exponential backoff.
- const randomDelay = Math.floor(Math.random() * 1000); - console.log('Sleeping for', randomDelay, 'ms...'); - await new Promise((resolve) => setTimeout(resolve, randomDelay)); + // Add exponential backoff with jitter + const baseDelay = 500; + const attempt = i + 1; + const maxDelay = Math.min(baseDelay * Math.pow(2, attempt), 5000); + const delay = Math.floor(maxDelay * (0.5 + Math.random() * 0.5)); + console.log(`Sleeping for ${delay} ms (attempt ${attempt})...`); + await new Promise((resolve) => setTimeout(resolve, delay));
31-50: Consider adding command-line parameters for better testability.The test function lacks configurability, making it difficult to use in different environments or for different testing scenarios.
Add command-line parameter support:
import { faker } from '@faker-js/faker'; import { Resend } from 'resend'; import minimist from 'minimist'; const arr = [ // existing email templates ]; const runTest = async (options: { apiKey: string; recipient: string; count?: number; maxDelay?: number; }) => { const resend = new Resend(options.apiKey); const emailsToSend = options.count ? arr.slice(0, options.count) : arr; for (const item of emailsToSend) { const response = await resend.emails.send({ from: `${faker.person.firstName().toLowerCase()}@n8n.new`, to: options.recipient, subject: item.subject, html: item.text, }); const randomDelay = Math.floor(Math.random() * (options.maxDelay || 1000)); console.log('Sleeping for', randomDelay, 'ms...'); await new Promise((resolve) => setTimeout(resolve, randomDelay)); if (response.error) { console.log('Error sending email:', response.error); } else { console.log('Email sent successfully'); } } }; // Parse command line arguments const argv = minimist(process.argv.slice(2)); const apiKey = argv.key || process.env.RESEND_API_KEY; const recipient = argv.to || process.env.TEST_RECIPIENT_EMAIL; if (!apiKey) { console.error('No API key provided. Use --key or set RESEND_API_KEY env variable'); process.exit(1); } if (!recipient) { console.error('No recipient provided. Use --to or set TEST_RECIPIENT_EMAIL env variable'); process.exit(1); } runTest({ apiKey, recipient, count: argv.count ? parseInt(argv.count, 10) : undefined, maxDelay: argv.delay ? parseInt(argv.delay, 10) : undefined });apps/mail/components/create/email-input.tsx (3)
88-98: Consider enhancing keyboard navigation for better UX.The keyboard handling is good for Enter and Escape, but consider adding Tab support to allow users to quickly edit multiple email addresses in sequence.
const handleEditKeyDown = (e: React.KeyboardEvent<HTMLInputElement>, index: number) => { if (e.key === 'Enter') { e.preventDefault(); onEditEmail(type, index, editValue); setEditingIndex(null); setEditValue(''); } else if (e.key === 'Escape') { setEditingIndex(null); setEditValue(''); + } else if (e.key === 'Tab' && !e.shiftKey && index < emails.length - 1) { + e.preventDefault(); + onEditEmail(type, index, editValue); + handleChipClick(index + 1, emails[index + 1]); + } else if (e.key === 'Tab' && e.shiftKey && index > 0) { + e.preventDefault(); + onEditEmail(type, index, editValue); + handleChipClick(index - 1, emails[index - 1]); } };
113-133: Add validation and consider accessibility improvements for the edit input.The conditional rendering of the editable input looks good, but consider adding:
- Email validation before submitting the edit
- ARIA attributes for better screen reader support
- Potentially save changes on blur rather than discarding them
{editingIndex === index ? ( <div className="relative flex items-center"> <input ref={editInputRef} type="text" value={editValue} onChange={(e) => setEditValue(e.target.value)} onKeyDown={(e) => handleEditKeyDown(e, index)} - onBlur={() => setEditingIndex(null)} + onBlur={() => { + // Optional: validate and save on blur + const isValid = /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(editValue.trim()); + if (isValid && editValue !== email) { + onEditEmail(type, index, editValue); + } + setEditingIndex(null); + setEditValue(''); + }} className="w-[150px] bg-transparent focus:outline-none pr-6" + aria-label={`Edit email address ${email}`} /> <span className="absolute right-1 text-xs text-muted-foreground">↵</span> </div> ) : ( <span onClick={() => handleChipClick(index, email)} className="max-w-[150px] cursor-pointer overflow-hidden text-ellipsis whitespace-nowrap" + aria-label={`Click to edit: ${email}`} + role="button" + tabIndex={0} + onKeyDown={(e) => { + if (e.key === 'Enter' || e.key === ' ') { + handleChipClick(index, email); + } + }} > {email} </span> )}
102-102: CSS class concatenation can be simplified with template literals.The CSS class concatenation is correct but can be simplified for better readability.
- <div className={`text-muted-foreground flex-shrink-0 pr-3 text-[1rem] font-[600] opacity-50 ${className}`}> + <div className={`text-muted-foreground flex-shrink-0 pr-3 text-[1rem] font-[600] opacity-50 ${className ?? ''}`}>
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
bun.lockis excluded by!**/*.lock
📒 Files selected for processing (13)
apps/mail/actions/mail.ts(1 hunks)apps/mail/actions/send.ts(4 hunks)apps/mail/app/api/driver/google.ts(1 hunks)apps/mail/app/api/driver/types.ts(1 hunks)apps/mail/components/context/thread-context.tsx(3 hunks)apps/mail/components/create/create-email.tsx(8 hunks)apps/mail/components/create/email-input.tsx(4 hunks)apps/mail/i18n/config.ts(1 hunks)apps/mail/locales/en.json(2 hunks)apps/mail/locales/zh_CN.json(1 hunks)apps/mail/locales/zh_TW.json(1 hunks)apps/mail/package.json(1 hunks)apps/mail/scripts.ts(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (6)
apps/mail/app/api/driver/types.ts (1)
apps/mail/types/index.ts (1)
IOutgoingMessage(110-120)
apps/mail/actions/send.ts (1)
apps/mail/app/api/driver/google.ts (1)
driver(195-1061)
apps/mail/actions/mail.ts (2)
apps/mail/app/api/driver/google.ts (1)
driver(195-1061)apps/mail/actions/utils.ts (3)
getActiveDriver(33-63)FatalErrors(9-9)deleteActiveConnection(11-31)
apps/mail/app/api/driver/google.ts (1)
apps/mail/types/index.ts (1)
IOutgoingMessage(110-120)
apps/mail/components/context/thread-context.tsx (1)
apps/mail/actions/mail.ts (1)
deleteThread(117-128)
apps/mail/components/create/create-email.tsx (1)
apps/mail/actions/send.ts (1)
sendEmail(7-67)
🔇 Additional comments (20)
apps/mail/package.json (1)
69-69:Details
✅ Verification successful
Added DOMPurify for HTML sanitization
The addition of DOMPurify (^3.2.5) is a good security practice for sanitizing HTML content in email handling to prevent XSS attacks.
Let's verify if this is the latest version with all security patches:
🏁 Script executed:
#!/bin/bash # Check for the latest version of DOMPurify and any security advisories npm view dompurify versions --json | jq '.[-5:]' npm view dompurify time --json | jq '.modified' # Check for any security vulnerabilities npm audit --json | jq '.advisories[] | select(.module_name=="dompurify")' || echo "No vulnerabilities found for DOMPurify"Length of output: 753
DOMPurify dependency verified as up-to-date and secure
- apps/mail/package.json (line 69):
"dompurify": "^3.2.5"- Latest release is 3.2.5 (published 2025-04-03)
- No known security advisories found
All checks pass—this change can be merged.
apps/mail/app/api/driver/types.ts (1)
13-13: Added sendDraft method to MailManager interfaceThe new method provides a clear API contract for sending an existing draft email by its ID, distinguishing it from creating new emails. This implementation aligns with the feature for sending draft emails.
apps/mail/i18n/config.ts (1)
4-5: Added support for Traditional and Simplified Chinese languagesThe addition of Chinese language options expands the internationalization capabilities of the application, providing better accessibility for Chinese-speaking users.
apps/mail/actions/send.ts (3)
17-17: Added draftId parameter to sendEmail functionThe optional draftId parameter enables the function to handle both new emails and sending existing drafts, maintaining backward compatibility while extending functionality.
Also applies to: 28-28
48-58: Refactored email data into a separate objectGood refactoring that improves code readability and reduces duplication when calling either sendDraft or create methods.
60-64: Added conditional logic for sending drafts vs. new emailsThe implementation correctly handles both cases - sending an existing draft when draftId is provided, or creating a new email otherwise.
apps/mail/locales/en.json (2)
22-24: Appropriate localization strings for mail deletion actions.These new status messages for deleting mail follow the existing pattern for action notifications and provide clear user feedback during the deletion process.
255-255: Command label added properly for the new deletion action.The "Delete from Bin" command label is correctly added to support the new context menu option in the mail UI.
apps/mail/app/api/driver/google.ts (1)
835-853: Correctly implementedsendDraftmethod.The
sendDraftimplementation follows the established patterns for mail driver methods:
- Properly calls
parseOutgoingto prepare message data- Uses
withErrorHandlerwith appropriate operation name and context- Correctly structures the Gmail API call with proper parameters
This enables sending draft emails through the UI and provides consistent error handling.
apps/mail/components/context/thread-context.tsx (2)
29-29: Import statement updated correctly.The import statement has been correctly updated to include the new
deleteThreadfunction.
285-291: Well-implemented delete action in the context menu.The new context menu item is correctly added to the bin folder actions, with appropriate icon and label references for localization. The action is properly connected to the
handleDeletefunction.apps/mail/locales/zh_TW.json (1)
1-450: LGTM: Well-structured locale file for Traditional Chinese.The structure aligns with standard localization patterns, providing empty placeholders for all needed translations. Ensure translators fill these values before deployment to Chinese-speaking regions.
apps/mail/components/create/create-email.tsx (4)
271-288: Good implementation of inline email editing.The
handleEditEmailfunction properly handles validation and state updates for editing email addresses. The error handling with toast notification provides good user feedback.
357-375: Refactored email sending with draft support.Good refactoring to support both draft and new email sending through a unified interface. The construction of
emailDataand conditional sending logic improves maintainability.
600-600: Consistent implementation of editing across all email fields.The
onEditEmailprop is consistently added to allEmailInputcomponents (to, cc, bcc), ensuring that inline editing works uniformly across the interface.Also applies to: 616-616, 633-633
817-817: Minor CSS class order change with no functional impact.The order of
max-h-[40vh]andtouch-autoCSS classes was swapped, which doesn't affect the component's appearance or behavior.apps/mail/locales/zh_CN.json (1)
1-450: LGTM: Well-structured locale file for Simplified Chinese.The structure follows the same pattern as the Traditional Chinese file and aligns with the application's localization needs. Remember to have translators fill these values before deployment to Chinese-speaking regions.
apps/mail/components/create/email-input.tsx (3)
14-14: Well-implemented inline editing feature with proper prop addition.The new
onEditEmailprop is correctly typed and integrated into both the interface and component parameters, allowing the parent component to handle email address updates properly.Also applies to: 29-29
35-39: Good state management for editing functionality.The state variables for tracking editing state (
editingIndex,editValue) and the additional ref (editInputRef) are appropriately designed for managing the inline editing experience.
74-86: Effective chip click handler with proper focus management.The
handleChipClickfunction correctly sets up the editing state and usessetTimeoutto ensure the DOM is updated before attempting to focus the input. The cursor positioning at the end of the text is a nice UX touch.
Summary by CodeRabbit